/*
 * Copyright 2013 Krzysztof Smigielski
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.nilcaream.dirstore.cli.command;

import com.google.common.base.Charsets;
import com.google.common.io.Resources;
import com.nilcaream.dirstore.cli.Configuration;
import org.slf4j.Logger;

import javax.inject.Inject;
import java.io.IOException;

/**
 * TODO
 * <p/>
 * Krzysztof Smigielski 4/20/13 8:30 PM
 */
public class ShowHelp implements Command {

    @Inject
    private Logger logger;

    @Inject
    private Configuration configuration;

    @Override
    public void execute() {
        try {
            for (String string : Resources.readLines(Resources.getResource("man.txt"), Charsets.UTF_8)) {
                logger.info(string);
            }
        } catch (IOException e) {
            logger.error("Unable to read help file", e);
        }
    }

    @Override
    public boolean isValid() {
        return configuration.isShowHelp();
    }
}
